package com.muzi.proxy;

import com.muzi.factory.FarmEquipment;

// 访问控制代理类
public class AuthorizedAccessProxy implements FarmEquipment {
    private final FarmEquipment realEquipment;//农场设备
    private final boolean authorized; //是否授权

    public AuthorizedAccessProxy(FarmEquipment realEquipment, boolean authorized) {
        this.realEquipment = realEquipment;
        this.authorized = authorized;
    }
    @Override
    public void operate() {
        if (authorized) {
            realEquipment.operate(); // 可以访问
        } else {
            System.out.println("访问被拒绝：无权限操作农机设备。");
        }
    }}
